// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
import Axios from 'axios'
import BootstrapVue from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
import directives from './utils/directives.js'

Vue.config.productionTip = false;

Vue.use(BootstrapVue);
Vue.use(mavonEditor);
Vue.use(directives);

router.beforeEach ((to,from,next) =>{
  if(to.matched.some( m => m.meta.auth)){
    if(store.state.login.isUser == true) {
      next()
    }
    else {
      next({ path:'/' })
    }
  }
  else {
    next()
  } 
});
router.afterEach((to, from, next) => window.scrollTo(0,0));

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  store,
  template: '<App/>'
})
